package com.vichat.task;

import com.alibaba.dubbo.container.spring.SpringContainer;
import com.vichat.res.service.ICfgService;
import com.vichat.task.service.ITask;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.context.ApplicationContext;
import org.springframework.stereotype.Component;

/**
 * Created by wangluyin on 2017/9/6.
 */
@Component("GenerateDMTableTask")
public class GenerateDMTableTask implements ITask {
    private static transient final Logger logger = LoggerFactory.getLogger(GenerateDMTableTask.class);

    ICfgService cfgService;

    public String doTask(long cfgTaskId) throws Exception {
        ApplicationContext ctx = SpringContainer.getContext();
        cfgService = (ICfgService) ctx.getBean("cfgService", ICfgService.class);
        cfgService.executeSql("{call cfgdb.generate_day_table()}");
        cfgService.executeSql("{call cfgdb.generate_month_table()}");
        return "success";
    }



}
